<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>es6中的类</title>
</head>
<body>
	<script>
		// 1、es6中定义类
		class person{
			constructor(name,age){
				this.name = name || "default name1";
				this.age = age || "default age1";
				this.like = {
					color:"red",
					height:180
				}
			};
			run(run){
				console.log(this.name+"---"+this.age + "---"+run+"----"+this.like.color)
			};
			static work(work){
				console.log(this.name +"--static--"+work)
			};
			// 访问器修改属性
			get color(){
				return this.like.color
			};
			set color(value){
				this.like.color= value+"====>访问器修改"
			};
			get height(){
				return this.like.height
			};
			set height(value){
				this.like.height= value+"====>访问器修改"
			};

		}

		var  people = new person("zhansan",13);
		people.run("跑步");
		person.work("跑步222222");
		people.color ="green";
		people.height = 998;
		console.log("通过服务器：", people.color,people.height);


		// 2、es6中定义类的继承
		console.log("-----es6中定义类的继承----------")
		class childPerson extends  person{
			constructor(name,age){
				super(name,age);
				this.sex = "男"
			};
			doing(doing){
				console.log(this.name+"----"+this.sex+"---"+this.age+"=="+doing)
			}
		}
		var  people2 = new childPerson("lsi",34);
			people2.doing("在工作");
		



	</script>
	
</body>
</html>